import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsArray } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';
import { Type } from 'class-transformer';

export class BaseAlarmDto {
  @ApiProperty({ required: false, description: 'id' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  id?: number;

  @ApiProperty({ required: false, description: '用户ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  userId?: number;

  @ApiProperty({ required: false, description: '孩子ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  childId?: number;

  @ApiProperty({ required: false, description: '报警类型（蓝色、红色、橙色等）' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  alarmType?: number;

  @ApiProperty({ required: false, description: '触发报警的对话内容' })
  @IsOptional()
  @IsString()
  alarmTriggerContent?: string;

  @ApiProperty({ enum: CharEnum, required: false, description: '删除标志' })
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({ required: false, description: '创建时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  createTime?: Array<string>;

  @ApiProperty({ required: false, description: '更新时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  updateTime?: Array<string>;
}

export class CreateAlarmDto extends OmitType(BaseAlarmDto, ['id', 'delFlag', 'createTime']) {}

export class UpdateAlarmDto extends OmitType(BaseAlarmDto, ['delFlag', 'createTime']) {}

export class QueryAlarmDto extends IntersectionType(BaseAlarmDto, PagingDto) {}

export class ListAlarmDto extends OmitType(BaseAlarmDto, ['delFlag', 'createTime', 'updateTime']) {}
